<?php require_once('../../core/import.php');?>
<?php User::Permission('FAQ_ADD'); ?>
<?php
    if($_SERVER['REQUEST_METHOD']=='POST')
    {
        #获取最大排序值
        $Data=DB::GetRows('select M_OrderWeight from `faq` order by M_OrderWeight desc limit 1');
        $OrderWeight=NULL;
        if($Data)
        {
            $OrderWeight=$Data[0]['M_OrderWeight'];
            if($OrderWeight){
                $OrderWeight+=1;
            }
            else{
                $OrderWeight=1;
            }
        }
        else{
           $OrderWeight=1;
        }


        #添加数据
        DB::Insert('faq',array
        (
            'ClassID'=>Functions::FormArgs('ClassID'),
            'Answer'=>Functions::FormArgs('Answer',NULL,FALSE),
            'Question'=>Functions::FormArgs('Question'),
            'Datetime'=>date('Y-m-d G:i:s'),
            'M_OrderWeight'=>$OrderWeight
        ));
        //信息统计
		User::Statistics_User('FAQ_ADD','faq','其它版块');
        echo '{"Number":"0","Description":"成功执行","ClassID":"'.Functions::FormArgs('ClassID').'"}';
    }
?>